package com.synjones.handsetS8.ild.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.provider.MediaStore;

import java.io.FileNotFoundException;

/**
 * @author Chris Chan
 * Create on: 2021/7/22}11:30
 * For:
 * Explain:
 */
public class BitmapUtil extends UtilsManager {
    /**
     * Bitmap转Uri
     *
     * @param bitmap
     * @return
     */
    public static Uri bmpToUri(Bitmap bitmap) {
        return Uri.parse(MediaStore.Images.Media.insertImage(mContext.getContentResolver(), bitmap, null, null));
    }

    /**
     * Uri转Bitmap
     *
     * @param context
     * @param uri
     * @return
     */
    public static Bitmap uriToBmp(Context context, Uri uri) throws FileNotFoundException {
        return BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri));
    }
}
